// src\store\index.ts
import { defineStore } from 'pinia';

const useStore = defineStore('menu', {
  state: () => ({
    isCollapse: false,
    indexMenu: [
      {
        title: '',
        collapseShow: true,
        items: [
          {
            label: '首页',
            icon: '🏠',
            link: '/',
          },
          {
            label: '搜索',
            icon: '🔍',
            link: '/explore',
          },
          {
            label: '订阅',
            icon: '📺',
            link: '/subscriptions',
          },
        ],
      },
    ],
    isLoadingMenu: false,
  }),
  getters: {},
  actions: {
    updateIndexMenu(indexMenu: any[]) {
      if (indexMenu) {
        this.indexMenu = indexMenu;
      }
    },
    updateIsLoadingMenu(load: boolean) {
      this.isLoadingMenu = load;
    },
  },
  persist: {
    key: 'MENU_STATE',
    // 修改为 sessionStorage，默认为 localStorage
    storage: window.sessionStorage,
  },
});

export default useStore;
